load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library", "go_test")
load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library")
load("@rules_proto//proto:defs.bzl", "proto_library")
load(":build_defs.bzl", "documentation")

documentation(
    name = "warnings_docs",
    bin = ":go_default_binary",
    markdown = "WARNINGS.md",
    textproto = "warnings.textproto",
)

go_binary(
    name = "go_default_binary",
    embed = [":docs_lib"],
    visibility = ["//visibility:public"],
)

go_library(
    name = "docs_lib",
    srcs = ["docs.go"],
    importpath = "github.com/bazelbuild/buildtools/warn/docs",
    visibility = ["//visibility:private"],
    deps = [
        ":proto_go_proto",
        "//warn",
        "@com_github_golang_protobuf//proto:go_default_library",
    ],
)

go_test(
    name = "docs_test",
    size = "small",
    srcs = ["docs_test.go"],
    data = [
        "warnings.textproto",
        ":warnings_docs",
        "//:warnings",
    ],
    embed = [":docs_lib"],
    deps = [
        "//testutils",
        "//warn",
    ],
)

proto_library(
    name = "docs_proto",
    srcs = ["docs.proto"],
    visibility = ["//visibility:public"],
)

go_proto_library(
    name = "proto_go_proto",
    importpath = "github.com/bazelbuild/buildtools/warn/docs/proto",
    proto = ":docs_proto",
    visibility = ["//visibility:public"],
)
